const app = getApp()
import util from '../../../utils/util'
import {
  GetMenuList,
  getBasicPolicy
} from '../../../config/api'
Page({

  /**
   * 页面的初始数据
   */
  data: {
    pid:'',
    active: 0,
    list:[],//班子成员列表
    isEmpty:false,//是否显示暂无数据，默认不显示
    page:1,
    limit:100000000,
  },

  /**
 * 生命周期函数--监听页面加载
 */
  onLoad: function (options) {
    console.log('组织架构options:', options);
    this.setData({
      pid:options.pid
    })
  
    let params = {
      vollege_id: app.globalData.vollege_id,
      page: 1,
      limit: 100000,
    }
    let newParams = Object.assign(params, options);
    console.log('newParams:', newParams);
    this.getBasicList(newParams);
    this.getTabList()
  },

  getTabList() {
    let that = this;
    util.apiRequest(GetMenuList, {
      type: "mini",
      pid: that.data.pid,
      vollege_id: app.globalData.vollege_id
    }, null).then(r => {
      console.log("tab栏目数据：", r);
      if (r.data.data.length > 0) {
        that.setData({
          columns: r.data.data
        })
      } 
      //that.getArticleList();
    });
  },

  //获得基层党建列表
  getBasicList(params){
    let that = this;
    util.apiRequest(getBasicPolicy,params,null).then(r=>{
      console.log('组织架构：',r.data.data);
      that.setData({
        list:r.data.data
      });
      if(r.data.data.length==0){
         that.setData({
           isEmpty:true
         });
      }else{
        that.setData({
          isEmpty:false
        });
      }
    });
  },

  SwitchStatus: function (e) {
    // 传递的参数
    let index = e.currentTarget.dataset['index'];
    let item = e.currentTarget.dataset['item'];
    console.log('切换点击item：', item)
    // this.setData({
    //   active: index
    // })
    wx.redirectTo({
      url: '/pages/village/village?'+ item.param + '&pid=' + item.pid + '&active=' +index
    })
  },

 //拨打电话
 dial(e){
  let that = this;
  console.log('e',e.currentTarget.dataset.phone);
  wx.makePhoneCall({
   phoneNumber: e.currentTarget.dataset.phone //仅为示例，并非真实的电话号码
 })
 },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})